package view.screen;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.StringItem;

import view.MVCComponent;

/**
 * Base class to create help/tips views
 * 
 * @author Marcelo Gatto
 */
public abstract class GenericHelp extends MVCComponent {
	
	private static final Command cmd_back = new Command("Back", Command.BACK, 2);
	
	protected Form form;
	
	public GenericHelp(MVCComponent baseView) {
		setCallerView(baseView);
		
		form = new Form("Help");
		form.addCommand(cmd_back);
	}
	
	/**
	 *  Overwrite to define the text
	 */
	protected abstract String getHelpText();
	
	protected void createView() {
		StringItem sItem = new StringItem("",  getHelpText(), Item.PLAIN);
		form.append(sItem);
	}
		
	public void commandAction(Command cmd, Displayable arg1) {
		if(cmd == cmd_back) {
			showCallerView();
		}
	}

	public Displayable getScreen() {
		return form;
	}
	
	protected void initModel()  {
	}

	protected void updateView() {
		createView();
	}

}